home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / user-setup / functions.sh next >
Encoding:
Text File  |  2007-02-15  |  1.1 KB  |  42 lines

  1. # Returns a true value if there seems to be a system user account.
  2. is_system_user () {
  3.     if ! [ -e $ROOT/etc/passwd ]; then
  4.         return 1
  5.     fi
  6.     
  7.         # Assume NIS, or any uid from 1000 to 29999,  means there is a user.
  8.         if grep -q '^+:' $ROOT/etc/passwd || \
  9.            grep -q '^[^:]*:[^:]*:[1-9][0-9][0-9][0-9]:' $ROOT/etc/passwd || \
  10.            grep -q '^[^:]*:[^:]*:[12][0-9][0-9][0-9][0-9]:' $ROOT/etc/passwd; then
  11.                 return 0
  12.         else
  13.                 return 1
  14.         fi
  15. }
  16.  
  17. # Returns a true value if root already has a password.
  18. root_password () {
  19.     if ! [ -e $ROOT/etc/passwd ]; then
  20.         return 1
  21.     fi
  22.     
  23.     # Assume there is a root password if NIS is being used.
  24.     if grep -q '^+:' $ROOT/etc/passwd; then
  25.         return 0
  26.     fi
  27.  
  28.     if [ -e $ROOT/etc/shadow ] && \
  29.        [ "`grep ^root: $ROOT/etc/shadow | cut -d : -f 2`" ] && \
  30.        [ "`grep ^root: $ROOT/etc/shadow | cut -d : -f 2`" != '*' ]; then
  31.         return 0
  32.     fi
  33.     
  34.     if [ -e $ROOT/etc/passwd ] && \
  35.         [ "`grep ^root: $ROOT/etc/passwd | cut -d : -f 2`" ] && \
  36.         [ "`grep ^root: $ROOT/etc/passwd | cut -d : -f 2`" != 'x' ]; then
  37.             return 0
  38.     fi
  39.  
  40.     return 1
  41. }
  42.